package datademo;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class DateDemo {
    public static void main(String[] args) throws ParseException {
        Date date = new Date();
        System.out.println(date);
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
        String format = simpleDateFormat.format(date);
        //Date转字符
        System.out.println(format);
        String  dateStr="2020-12-12";
        Date parse = simpleDateFormat.parse(dateStr);
        System.out.println(parse);

    }
}
